<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // const formatDate = date => {
    //   const year = date.getFullYear();
    //   const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以加1
    //   const day = String(date.getDate()).padStart(2, '0');
    //   return `${year}-${month}-${day}`;
    // }
    // const calculateNextPeriod = (startTime, circleMonthTime, diffMonth = 0) => {
    //   const startDate = new Date(startTime); // 将字符串转换为日期对象
    //   const currentDate = new Date(); // 获取当前日期

    //   // 计算从开始日期到当前日期的总月数
    //   const monthsSinceStart = (currentDate.getFullYear() - startDate.getFullYear()) * 12 + (currentDate.getMonth() - startDate.getMonth());

    //   // 计算距离最近的周期结束的月数
    //   let monthsToNextPeriod;
    //   if (monthsSinceStart % circleMonthTime === 0) monthsToNextPeriod = circleMonthTime; // 如果正好在周期结束时，直接进入下一个周期
    //   else monthsToNextPeriod = circleMonthTime - (monthsSinceStart % circleMonthTime); // 否则，计算到下一个周期结束的月数

    //   // 创建下一个周期结束的日期对象
    //   const nextPeriodEndDate = new Date(currentDate.getFullYear() + Math.floor((currentDate.getMonth() + monthsToNextPeriod) / 12), ((currentDate.getMonth() + monthsToNextPeriod) % 12) % 12 + diffMonth, startDate.getDate());

    //   // return formatDate(nextPeriodEndDate)// 返回结果, 只保留日期部分
    //   return nextPeriodEndDate
    // }

    // const a = (registerTime, lastCheckTime) => {
    //   const diffMonth = 3; //截止日期前，3个月内办理下一次的车检
    //   const nowDate = new Date(); // 获取当前日期
    //   const lastCheckDate = new Date(lastCheckTime); // 获取当前日期
    //   const registerDate = new Date(registerTime); // 将字符串转换为日期对象
    //   const exemptCheckDate = new Date(registerDate.getFullYear() + 6, registerDate.getMonth(), registerDate.getDate() + 1);
    //   const perYearCheckDate = new Date(registerDate.getFullYear() + 15, registerDate.getMonth(), registerDate.getDate() + 1);

    //   let checkStatus; // 0未年检(年检超期) 1已年检
    //   let exemptStatus; // 0需年检 1免年检
    //   let nextCheckTime;

    //   let period;
    //   const isExempt = nowDate < exemptCheckDate;
    //   const isBetween6And15 = nowDate >= exemptCheckDate && nowDate <= perYearCheckDate;
    //   const isOver15 = nowDate > perYearCheckDate;

    //   if (isExempt) period = 2 * 12;
    //   else if (isBetween6And15) period = 1 * 12;
    //   else period = 0.5 * 12;

    //   const nextPeriodDate = calculateNextPeriod(registerTime, period);
    //   const nextPeriodDiffDate = new Date(nextPeriodDate.getFullYear(), nextPeriodDate.getMonth() - diffMonth, nextPeriodDate.getDate())
    //   const lastPeriodDate = new Date(nextPeriodDate.getFullYear() - period / 12, nextPeriodDate.getMonth(), nextPeriodDate.getDate())
    //   const lastPeriodDiffDate = new Date(nextPeriodDate.getFullYear() - period / 12, nextPeriodDate.getMonth() - diffMonth, nextPeriodDate.getDate())

    //   console.log(formatDate(exemptCheckDate), 'exemptCheckDate');
    //   console.log(isExempt, isBetween6And15, isOver15);
    //   console.log(formatDate(nowDate), 'nowDate');
    //   console.log(formatDate(nextPeriodDate), 'nextPeriodDate');
    //   console.log(formatDate(nextPeriodDiffDate), 'nextPeriodDiffDate');
    //   console.log(formatDate(lastPeriodDate), 'lastPeriodDate');
    //   console.log(formatDate(lastPeriodDiffDate), 'lastPeriodDiffDate');

    //   if (nowDate >= lastPeriodDate && nowDate < nextPeriodDiffDate) {
    //     console.log('a');
    //     if (lastCheckDate < lastPeriodDiffDate) {
    //       checkStatus = 0
    //       exemptStatus = isExempt ? 1 : 0
    //       nextCheckTime = ''
    //       console.log('1');
    //     }
    //     if (lastCheckDate >= lastPeriodDiffDate && lastCheckDate <= nowDate) {
    //       checkStatus = 1
    //       exemptStatus = isExempt ? 1 : 0
    //       nextCheckTime = formatDate(nextPeriodDate);
    //       console.log('2');
    //     }
    //   }
    //   if (nowDate >= nextPeriodDiffDate && nowDate < nextPeriodDate) {
    //     console.log('b');
    //     if (lastCheckDate < lastPeriodDiffDate) {
    //       checkStatus = 0
    //       exemptStatus = isExempt ? 1 : 0
    //       nextCheckTime = '';
    //       console.log('3');
    //     }
    //     if (lastCheckDate >= lastPeriodDiffDate && lastCheckDate < nextPeriodDiffDate) {
    //       checkStatus = 1
    //       exemptStatus = isExempt ? 1 : 0
    //       nextCheckTime = formatDate(nextPeriodDate);
    //       console.log('4');
    //     }
    //     if (lastCheckDate >= nextPeriodDiffDate && lastCheckDate < nextPeriodDate) {
    //       checkStatus = 1
    //       exemptStatus = isExempt ? 1 : 0
    //       nextCheckTime = formatDate(calculateNextPeriod(registerTime, period, period)); //再下一次的时间
    //       console.log('5');
    //     }
    //   }

    //   console.log({ checkStatus, exemptStatus, nextCheckTime });
    // }

    // // 2024
    // // a('2019-08-31', '2023-07-05')
    // a('2018-04-23', '2024-01-20')
    // // a('2015-05-23', '2024-05-20')

    // const getUuid = () => {
    //   const timestamp = String(new Date().getTime())
    //   const random = Math.random() * (timestamp.length - 5 + 1)
    //   const floor = Math.floor(random)
    //   const res = Number(timestamp.substring(floor, floor + 5))
		//   console.log('-----------------', timestamp, random, floor, res);
    // }

    // getUuid();
    // getUuid();

    const order = [
      { id: 0, price: 10 },
      { id: 1, price: 30 },
      { id: 2, price: 50 },
    ]

    console.log('price', order.reduce((acc, cur) => {
      console.log(acc, cur);
      return acc + cur.price
    }, 0));
  </script>
</body>

</html>